package com.pet.pet05order.controller;

import com.pet.pojo.Order;
import com.pet.pojo.OrderPre;
import com.pet.service.OrderService;
import com.pet.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /*http://localhost:8301/order/addOrder*/
    /*生成单个订单*/
    @PostMapping("/addOrder")
    public SysResult addOrder(String userName,Integer itemId,Integer num){
        System.out.println(userName);
        System.out.println(itemId);
        System.out.println(num);
        Boolean flag = orderService.addOrder(userName,itemId,num);
        return SysResult.success();
    }
    /*http://localhost:8301/order/getAllOrder*/
    /*获取所有订单信息*/
    @GetMapping("/getAllOrder")
    public SysResult getAllOrder(String userName){
        List<Order> orders = orderService.getAllOrder(userName);
        return SysResult.success(orders);
    }
}
